﻿using System;
using System.Collections.Generic;
using System.Data;
using Module.Common.Models;
using Module.Core.DAO;
using Module.Core.EntitiesInfo;

namespace Module.Core.BusinessLogic
{
    public class UpgradeAccount
    {
        /// <summary>
        /// Saves a record to the UpgradeAccount table.
        /// </summary>
        public static int Insert(UpgradeAccountInfo upgradeAccountInfo)
        {
            try
            {
                return new UpgradeAccountDAO().Insert(upgradeAccountInfo);
            }
            catch (Exception ex)
            {
                throw;
            }

        }

        /// <summary>
        /// Saves a record to the UpgradeAccount table.
        /// </summary>
        public static void Update(UpgradeAccountInfo upgradeAccountInfo)
        {
            try
            {
                new UpgradeAccountDAO().Update(upgradeAccountInfo);
            }
            catch (Exception ex)
            {
                throw;
            }

        }
        /// <summary>
        /// Cập nhật status khi khách hàng nâp cấp
        /// price=2000->status=3  -khách hàng bạc
        /// price=4000->status=2  -Khách hàng vàng
        /// price=6000->status=1  -Khách hàng kim cương
        /// 
        /// </summary>

        public static void UpdateStatus(int idMember, int status)
        {
            try
            {
                new UpgradeAccountDAO().UpdateStatus(idMember, status);
            }
            catch (Exception ex)
            {
                throw;
            }

        }
        public static int SelectCount(string codeMember,string email)
        {
            try
            {
                return new UpgradeAccountDAO().SelectCount(codeMember,email);
            }
            catch (Exception ex)
            {
                throw;
            }

        }

        public static DataTable Search(string codeMember,string email,int beginRow, int endRow, string orderByColumn)
        {
            try
            {
                return new UpgradeAccountDAO().Search(codeMember,email, beginRow, endRow, orderByColumn);
            }
            catch (Exception ex)
            {
                throw;
            }

        }


        /// <summary>
        /// Delete a record from the UpgradeAccount table.
        /// </summary>
        public static void Delete(int id)
        {
            try
            {
                new UpgradeAccountDAO().Delete(id);
            }
            catch (Exception ex)
            {
                throw;
            }

        }

        /// <summary>
        /// Selects a single record from the UpgradeAccount table.
        /// </summary>
        public static UpgradeAccountInfo Select(int status, string param)
        {
            try
            {
                return new UpgradeAccountDAO().Select(status, param)
                ;
            }
            catch (Exception ex)
            {
                throw;
            }

        }

        /// <summary>
        /// Selects all records from the UpgradeAccount table.
        /// </summary>
        public static CHRTList<UpgradeAccountInfo> SelectAll()
        {
            try
            {
                return new UpgradeAccountDAO().SelectAll();
            }
            catch (Exception ex)
            {
                throw;
            }

        }

        public static int SumPrice(string status, string param)
        {
            try
            {
                return new UpgradeAccountDAO().SumPrice(status, param);
            }
            catch (Exception ex)
            {
                throw;
            }

        }
    }
}
